﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HospitalInstallManage.aspx.cs" Inherits="RegisterWeb.Manager.HospitalManager.ManageHospitalInstall" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/gray/easyui.css" rel="stylesheet"
        type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>


<script type="text/javascript">

    var url; //提交数据的路径
    var formId; //当天要提交的Form的编号
    var dialogId; //对话框的编号

    var successCallback = function (result) {
        alert(result);
        //result为请求处理后的返回值
        var result = eval('(' + result + ')');
        if (result.success) {
            $.messager.show({
                title: 'Success',
                msg: result.msg
            });
            $(dialogId).dialog('close');
            $('#dg').datagrid('reload');
        } else {
            $.messager.show({
                title: 'Error',
                msg: result.msg
            });
        }
    }

    $(function () {
        //预加载编辑框
       // $("#editHospitalInstall").dialog('refresh');
        $("#editHospitalInstall").dialog({

            modal: true,
            "title": "编辑医院配置",
            width: 400,
            height: 330,
            href: 'EditHospitalInstall.aspx'
        });
        $("#editHospitalInstall").dialog('open').dialog('close');

        $('#dg').datagrid({

            onDblClickRow: function (rowIndex, rowData) {
                $('#editHospitalInstall').dialog('open');
                
                $("#HosptialInstall_StartRegistrationTime").timespinner('setValue', rowData.HosptialInstall_StartRegistrationTime);

                $('#HosptialInstall_BeforeDay').numberspinner('setValue', rowData.HosptialInstall_BeforeDay);
                //截取字符串并绑定到两个timespinner中
                var str = row.HosptiallInstall_WorkTime;
                var time = new Array();
                time = str.toString().split("~");
                $('#HosptiallInstall_WorkTime').timespinner('setValue', time[0]);
                $('#HosptiallInstall_WorkTime1').timespinner('setValue', time[1]);
               // $('#HosptiallInstall_WorkTime').timespinner('setValue', rowData.HosptiallInstall_WorkTime);

                $('#HosptiallInstall_AppointmentPhone').val(rowData.HosptiallInstall_AppointmentPhone);

                url = 'ashx/HospitalInstallHandler.ashx?action=editHospitalInstall&id=' + rowData.HospitalInstall_ID;
                formId = "#editInstall";
                dialogId = "#editHospitalInstall";

            }
        });

    });
    //编辑医院部分
    function editHospitalInstall() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
           // $("#editHospitalInstall").dialog('refresh');
            $('#editHospitalInstall').dialog('open');

            $("#HosptialInstall_StartRegistrationTime").timespinner('setValue', row.HosptialInstall_StartRegistrationTime);

            $('#HosptialInstall_BeforeDay').numberspinner('setValue', row.HosptialInstall_BeforeDay);
            //截取字符串并绑定到两个timespinner中
            var str = row.HosptiallInstall_WorkTime;
            var time = new Array();
            time = str.toString().split("~");
            $('#HosptiallInstall_WorkTime').timespinner('setValue', time[0]);
            $('#HosptiallInstall_WorkTime1').timespinner('setValue',time[1]);

            $('#HosptiallInstall_AppointmentPhone').val(row.HosptiallInstall_AppointmentPhone);

            url = 'ashx/HospitalInstallHandler.ashx?action=editHospitalInstall&id=' + row.HospitalInstall_ID;
            formId = "#editInstall";
            dialogId = "#editHospitalInstall";

        }
        else {
            $.messager.alert("提示", "您没有选中任何行！");
        }
    }
    //保存信息
    function saveInfo() {
        $(formId).form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: successCallback
        });
    }
    //  删除医院配置
   function deleteHospitalInstall() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $.messager.confirm('删除提示', '确定要删除' + row.Hospital_ID+'的配置吗', function (r) {
                if (r) {
                    $.post('ashx/HospitalInstallHandler.ashx', { id: row.HospitalInstall_ID, action: 'deleteHospitalInstall' }, function (data, status) {
                        if (data == "ok") {
                            $('#dg').datagrid('reload');
                            $.messager.show({
                                title: 'Success',
                                msg: '删除成功!'
                            });
                        } else {
                            $.messager.show({
                                title: 'Error',
                                msg: '删除失败!'
                            });
                        }
                    });
                }
            });
        }
    }

    /*function warn() {
        $("#warn").text("例如:http://www.baidu.com");

    }
    function hide() {
        $("#warn").text("");
    }*/
</script>

</head>
<body>
    <form id="form1" >
    <div region="center" title="医院配置管理" >
<table id="dg" title="医院配置管理" class="easyui-datagrid" style="width:850px;height:550px"
			url="ashx/HospitalInstallHandler.ashx?action=getHospitalInstall"
			toolbar="#toolbar" pagination="true"
			rownumbers="true" fitColumns="true" singleSelect="true" 
            pageSize="20"
            >
		<thead>
			<tr>
			<th field="Hospital_ID" width="50">

医院名称</th>
				<th field="HosptialInstall_StartRegistrationTime" width="50">放号时间</th>
				<th field="HosptialInstall_BeforeDay" 

width="30">提前天数</th>
				<th field="HosptiallInstall_WorkTime" 

width="50"> 工作时间</th>
  <th field="HosptiallInstall_AppointmentPhone"  width="50"> 预约号码</th>
                <th field="HospitalInstall_AddTime" width="50">添加时间</th>
                 <th field="HospitalInstall_Recoder" width="50">记录者</th>
                 <th field="HospitalInstall_ID" width="50" hidden="true">配置ID

</th>
                
			</tr>
		</thead>
	</table>

    <div id="toolbar" style="padding:5px;height:auto">
				
                    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editHospitalInstall()">编辑医院配置</a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteHospitalInstall()">删除医院配置</a>
                   
    </div>


			<div id="addHospitalInstall" class="easyui-dialog" closed="true" buttons="#addHospitalInstall-buttons" style="padding:10px 20px">
        	</div>
			<div id="addHospitalInstall-buttons">
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveInfo()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick='$("#addHospitalInstall").dialog("close");'>关闭</a>
			</div>

            <div id="editHospitalInstall" class="easyui-dialog" closed="true" buttons="#editHospitalInstall-buttons" style="padding:10px 20px">
        	</div>
            <div id="editHospitalInstall-buttons">
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok"  onclick="saveInfo()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick='$("#editHospitalInstall").dialog("close");'>关闭</a>
			</div>

    </div>
    </form>
</body>
</html>
